package com.oracle.application.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author bug制造者
 * @ClassName RabbitMqConfig.java
 * @createTime 2021年07月08日 10:06:00
 * @Description
 */
@Configuration
public class RabbitMqConfig {

    //1、声明一个队列
    @Bean
    public Queue emailQueue(){
        return new Queue("emailQueue");
    }

    //2、声明一个交换机
    @Bean
    public DirectExchange emailExchange(){
        return new DirectExchange("emailExchange");
    }

    //3、将队列和交换机进行绑定
    @Bean
    public Binding queueExchangeBind(){
        return BindingBuilder.bind(emailQueue()).to(emailExchange()).with("send.email");
    }
}
